package cc.vv.btpartyjob.partyservice.adapter

import android.annotation.SuppressLint
import android.widget.ImageView
import android.widget.TextView
import cc.vv.baselibrary.adapter.SimpleCommonAdapter
import cc.vv.baselibrary.adapter.holder.ExtendViewHolder
import cc.vv.baselibrary.view.OvalImageView
import cc.vv.btpartyjob.partyservice.R
import cc.vv.btpartyjob.partyservice.module.bean.JobInfoBean
import cc.vv.lkimagecomponent2.LKImage
import cc.vv.lkimagecomponent2.lib.mode.ScaleMode

/**
 * 求职列表adapter
 * Created by Chen.qi on 2018/10/24.
 */
class PersonSearchAdapter(layoutResId: Int) : SimpleCommonAdapter<JobInfoBean>(layoutResId) {
    @SuppressLint("SetTextI18n")
    override fun convert(helper: ExtendViewHolder, item: JobInfoBean, position: Int) {

        //头像
        LKImage.load().scale(ScaleMode.CENTER_CROP)
                .crossFade(300).placeHolder(R.mipmap.icon_def_image)
                .error(R.mipmap.icon_def_image).load(item.faceUrl).into(helper.getView<OvalImageView>(R.id.lkv_ips_perHeadImg))
        //姓名
        helper.getView<TextView>(R.id.tv_ips_perName)?.text = item.name

        //年龄
        helper.getView<TextView>(R.id.tv_ips_personAge)?.text = "0岁"

        //学历
        helper.getView<TextView>(R.id.tv_ips_education)?.text = item.education

        //工作年限
        helper.getView<TextView>(R.id.tv_ips_experience)?.text = "${item.workYear}年"

        //求职岗位
        helper.getView<TextView>(R.id.tv_ips_applyPosition)?.text = "求职岗位：${item.careerObjective}"

        val viewSex = helper.getView<ImageView>(R.id.iv_ips_sex)

        if (0 == item.sex) {
            //男
            viewSex?.setImageResource(R.mipmap.icon_party_man)
        } else {
            //女
            viewSex?.setImageResource(R.mipmap.icon_party_woman)
        }
    }
}